package com.lotus.vigil.controller;


import com.lotus.vigil.model.DeviceFaultStats;
import com.lotus.vigil.service.FaultStatsService;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequiredArgsConstructor
public class FaultStatsController {
    private final FaultStatsService faultStatsService;

    @GetMapping("/api/faults/stats")
    public List<DeviceFaultStats> getFaultStats(
            @RequestParam("startTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
            @RequestParam("endTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime
    ){
        return faultStatsService.getFaultStats(startTime,endTime);
    }
}
